/* eslint no-undef: 0 */
/* eslint arrow-parens: 0 */
import React from 'react';

import Nav0 from './Nav0';
import Banner0 from './Banner0';
import Content0 from './Content0';
import Content1 from './Content1';
import Content2 from './Content2';
import Content3 from './Content3';
import Content4 from './Content4';
import Content5 from './Content5';
import Content6 from './Content6';
import Footer0 from './Footer0';

import {
  Nav00DataSource,
  Banner00DataSource,
  Content00DataSource,
  Content10DataSource,
  Content30DataSource,
  Footer00DataSource,
} from './data.source';
import './less/antMotionStyle.less';

type S = {
  isMobile?: boolean
  show: boolean
}

export default class Home extends React.Component<any, S> {
  dom: HTMLDivElement | null | undefined;
  constructor(props: any) {
    super(props);
    this.state = {
      show: false,
      isMobile: false
    }
  }

  componentDidMount() {
    if (location.port) {
      // 样式 build 时间在 200-300ms 之间;
      setTimeout(() => {
        this.setState({
          show: true,
        });
      }, 500);
    }
    /* 如果不是 dva 2.0 请删除 end */
  }

  render() {
    const children = [
      <Nav0
        id="Nav0_0"
        key="Nav0_0"
        dataSource={Nav00DataSource}
        isMobile={this.state.isMobile}
      />,
      <Banner0
        id="Banner0"
        key="Banner0"
        dataSource={Nav00DataSource}
        isMobile={this.state.isMobile}
      />,
      <Content0
        id="Content0"
        key="Content0"
        dataSource={Content00DataSource}
        isMobile={this.state.isMobile}
      />,
      <Content1
        id="Content1"
        key="Content1"
      />,
      <Content2
        id="Content2"
        key="Content2"
      />,
      <Content3
        id="Content3"
        key="Content3"
      />,
      <Content4
        id="Content4"
        key="Content4"
      />,
      <Content5
        id="Content5"
        key="Content5"
      />,
      <Content6
        id="Content6"
        key="Content6"
      />,
      <Footer0
        id="Footer0"
        key="Footer0"
      />,
    ];
    return (
      <div
        className="templates-wrapper"
        ref={(d) => {
          this.dom = d;
        }}
      >
        {/* 如果不是 dva 2.0 替换成 {children} start */}
        {this.state.show && children}
        {/* 如果不是 dva 2.0 替换成 {children} end */}
      </div>
    );
  }
}
